/*
进行local数据存储管理的工具模块
 */

/*
保存user
*/
// eslint-disable-next-line import/no-anonymous-default-export
import store from 'store'
//此处可能要存储openKey
const USER_KEY = 'user_key'
const OPEN_KEY = 'open_key'
const TAB_KEY = 'tab_key'
const ACTIVE_KEY = 'active_key'
// eslint-disable-next-line import/no-anonymous-default-export
export default {
    saveUser (user) {
        //localStorage.setItem(USER_KEY, JSON.stringify(user))
        store.set(USER_KEY,user)
    },

    getUser(){
        //return JSON.parse( localStorage.getItem(USER_KEY) || '{}' )
        return store.get(USER_KEY) || {}
    },

    //删除user
    removeUser () {
        //localStorage.removeItem(USER_KEY)
        store.remove(USER_KEY)
    },
    saveOpenKey (openKey) {
        //localStorage.setItem(USER_KEY, JSON.stringify(user))
        store.set(OPEN_KEY,openKey)
    },

    getOpenKey(){
        //return JSON.parse( localStorage.getItem(USER_KEY) || '{}' )
        return store.get(OPEN_KEY) || {}
    },

    //删除user
    removeOpenKey () {
        //localStorage.removeItem(USER_KEY)
        store.remove(OPEN_KEY)
    },

    saveTabs (tab) {
        //localStorage.setItem(USER_KEY, JSON.stringify(user))
        store.set(TAB_KEY,tab)
    },
    getTabs(){
        //return JSON.parse( localStorage.getItem(USER_KEY) || '{}' )
        return store.get(TAB_KEY) || {}
    },
    saveActive_key (key) {
        store.set(ACTIVE_KEY,key)
    },
    getActive_key (key) {
        return store.get(ACTIVE_KEY) || {}
    }

}
